#include "lua_environment.h"

#define _MODULE_NAME_ "LuaEnvironment"
using std::ifstream;
LuaEnvironment::LuaEnvironment() {
	lang_name = "LUA"; 
	lang_ver = string(LUA_RELEASE);
	L = lua_open(); if(!L) { E( _MODULE_NAME_ << " init failed.\n") L = NULL; return; }
	//luaL_openlibs(L); /* open all libraries */
	for(int i=0;i<sizeof(LUALOADLIBS);i++) load_state[i] = 0;
}

LuaEnvironment::~LuaEnvironment() {
	if(L)  {
		lua_close(L);
		L = NULL;
	}
}

void LuaEnvironment::load_restrictions(const char *filename) {
	ifstream ban_list(filename);
	char ban_name[1024];
	if(!ban_list) return;
	while(!ban_list.eof()) {
		ban_list.getline(ban_name,1024);
		remove_link(ban_name);
	}
}

